'''
Created on 10 Sep 2009

@author: jack
'''
import copy
dup=copy.deepcopy
def GenArrayList(shape1, xoffset,yoffset, gap=0,spacingx=0,spacingy=0,arrayx=0,arrayy=0):
#start a list of shapes  
    shape_list=[]
    if gap>0:
        if shape1.symmetry%2==0:
#Copy and displace, exploiting symmetry
            shape2=dup(shape1)
            shape2.TransShape(0,+shape1.length+gap)
        else:
#Copy, flip and displace.               
            shape2=dup(shape1)
            shape2.TransShape(0,+shape1.length+gap)
            shape2.FlipShapeY()   
    for x in range(0,arrayx+1, spacingx):
        for y in range(0,arrayy+1,spacingy):
            # generate a new shape, add it to the array list.
            temp=dup(shape1)
            temp.TransShape(x+xoffset,+y+yoffset)
            shape_list.append(temp)
            #if a dimer, copy the partner as well
            if gap>0:
                temp=dup(shape2)
                temp.TransShape(x+xoffset,+y+yoffset)
                shape_list.append(temp)
    return shape_list